var alldata='';
requetData();
function requetData() {
    $.ajax({
        url:"/moneydetails/moneylist" ,
        dataType:"json",
        type:"get",
        async:false,
        success:function (data) {
            console.log(data)
            showData(data)
            alldata= data
        }
    })

}

function add0(m){return m<10?'0'+m:m }

function format(shijianchuo)
{
    var time = new Date(shijianchuo);
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate()+1;

    return y+'-'+add0(m)+'-'+add0(d);

}
function  showData(jsonObj) {
    var html = ' <tr><th>游戏名称</th><th>购买价格</th><th>获取时间</th></tr>'

    for(var i = 0; i < jsonObj.length; i ++) {
        var date = format(jsonObj[i].glTime)
        html = html + "<tr><td>"
        html = html + jsonObj[i].gameName
        html = html + "</td><td>"
        html = html +  jsonObj[i].glPrice
        html = html + "</td><td>"
        html = html + date
        html = html + "</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>"
    }

    $('.table').html(html)
}

function sortLike() {
    var name = $('input[name="search"]').val()
    $.ajax({
        url:"/gamelibrary/selectgame"  ,
        data: "name=" + name,
        dataType:"json",
        type:"get",
        success:function (data) {
            console.log(data)
            showData(data)
        }
    })
}